package cn.calm.swing.osgi.generator.ui;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;

import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

import org.jdesktop.beansbinding.AutoBinding;
import org.jdesktop.beansbinding.AutoBinding.UpdateStrategy;
import org.jdesktop.beansbinding.BeanProperty;
import org.jdesktop.beansbinding.Bindings;
import org.jdesktop.observablecollections.ObservableCollections;
import org.jdesktop.swingbinding.JComboBoxBinding;
import org.jdesktop.swingbinding.SwingBindings;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;

import cn.calm.swing.osgi.api.ProjectPersistenceService;
import cn.calm.swing.osgi.api.ProjectService;
import cn.calm.swing.osgi.api.entity.Project;
import cn.calm.swing.osgi.api.exception.SwingException;
import cn.calm.swing.osgi.api.util.EntityUtil;
import cn.calm.swing.osgi.generator.entity.DatabaseInfo;
import cn.calm.swing.osgi.generator.entity.GeneratorInfo;
import cn.calm.swing.osgi.generator.service.GeneratorProjectService;
import cn.calm.swing.osgi.util.SwingHelper;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class Generator extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public static final String PROJECT_TYPE = "swing.osgi.generator";
	private JButton next;
	private JButton browe;
	private JTextField username;
	private JTextField port;
	private JComboBox databaseType;
	private JTextField database;
	private JPasswordField password;
	private JTextField hostname;
	private JTextField projectDir;
	private JCheckBox frameJPA;
	private JCheckBox frameBatis;
	private JCheckBox frameHibernate;
	private JCheckBox frameSping;
	private JCheckBox frameStruts;
	private JTextField group;
	private JTextField projectName;
	private JButton cancel;
	private JFileChooser chooser = new JFileChooser();
	private GeneratorInfo generatorInfo = new GeneratorInfo();
	private Project project = new Project();
	private List<DatabaseInfo> databaseInfos = new ArrayList<DatabaseInfo>();
	private BundleContext context;

	public Generator(BundleContext context) {
		this.context = context;
		databaseInfos = ObservableCollections.observableList(databaseInfos);
		setModal(true);
		Enumeration<URL> loader;
		JLabel projectDirLB;
		JLabel projectNameLb;
		JPanel jPanel1;
		JLabel hostnameLb;
		JPanel jPanel2;
		JLabel passwordLb;
		JLabel usernameLb;
		JLabel databaseLb;
		JLabel databaseTypeLb;
		JLabel portLb;
		JLabel groupLb;
		try {
			loader = Thread.currentThread().getContextClassLoader()
					.getResources("/driver/database.properties");
			Properties pro = new Properties();
			DatabaseInfo info = null;
			while (loader.hasMoreElements()) {
				InputStream is = null;
				info = new DatabaseInfo();
				try {
					is = loader.nextElement().openStream();
					pro.load(is);
					String val = String.valueOf(pro.get("databaseType"));
					info.setDatabaseType(val);
					val = String.valueOf(pro.get("url"));
					info.setUrl(val);
					val = String.valueOf(pro.get("port"));
					info.setPort(Integer.valueOf(val));
					val = String.valueOf(pro.get("driver"));
					info.setDriver(val);
					databaseInfos.add(info);
				} catch (Exception e) {
					e.printStackTrace();
				} finally {
					if (is != null) {
						is.close();
					}
				}
			}
		} catch (IOException e1) {
			e1.printStackTrace();
		}

		chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		BorderLayout thisLayout = new BorderLayout();
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		getContentPane().setLayout(thisLayout);
		{
			JPanel buttonPanel = new JPanel();
			FlowLayout buttonPanelLayout = new FlowLayout();
			buttonPanelLayout.setAlignment(FlowLayout.RIGHT);

			buttonPanel.setLayout(buttonPanelLayout);
			getContentPane().add(buttonPanel, BorderLayout.SOUTH);
			buttonPane(buttonPanel);
		}
		{
			JPanel pojectPanel = new JPanel();
			GridBagLayout pojectPanelLayout = new GridBagLayout();
			pojectPanelLayout.rowWeights = new double[] { 0.0 };
			pojectPanelLayout.rowHeights = new int[] { 30 };
			pojectPanelLayout.columnWeights = new double[] { 0.0, 0.1 };
			pojectPanelLayout.columnWidths = new int[] { 70, 7 };
			pojectPanel.setLayout(pojectPanelLayout);
			getContentPane().add(pojectPanel, BorderLayout.NORTH);
			{
				projectNameLb = new JLabel();
				pojectPanel.add(projectNameLb, new GridBagConstraints(0, -1, 1,
						1, 0.0, 0.0, GridBagConstraints.EAST,
						GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
				projectNameLb.setText("\u9879\u76ee\u540d:");
			}
			{
				projectName = new JTextField();
				pojectPanel.add(projectName, new GridBagConstraints(1, 0, 1, 1,
						0.0, 0.0, GridBagConstraints.WEST,
						GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				projectName.setPreferredSize(new java.awt.Dimension(495, 24));
			}
		}
		{
			JPanel contentPanel = new JPanel();
			GridBagLayout contentPanelLayout = new GridBagLayout();
			getContentPane().add(contentPanel, BorderLayout.EAST);
			contentPanel.setLayout(contentPanelLayout);
			contentPanel.setPreferredSize(new java.awt.Dimension(592, 247));
			{
				groupLb = new JLabel();
				contentPanel.add(groupLb, new GridBagConstraints(0, 0, 1, 1,
						0.0, 0.0, GridBagConstraints.EAST,
						GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
				groupLb.setText("\u9879\u76ee\u7ec4:");
			}
			{
				jPanel1 = new JPanel();
				GridBagLayout jPanel1Layout = new GridBagLayout();
				contentPanel.add(jPanel1, new GridBagConstraints(0, 2, 3, 1,
						0.0, 0.0, GridBagConstraints.CENTER,
						GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jPanel1Layout.rowWeights = new double[] { 0.0 };
				jPanel1Layout.rowHeights = new int[] { 30 };
				jPanel1Layout.columnWeights = new double[] { 0.1, 0.1, 0.1,
						0.1, 0.1 };
				jPanel1Layout.columnWidths = new int[] { 7, 7, 7, 20, 20 };
				jPanel1.setLayout(jPanel1Layout);
				jPanel1.setBorder(BorderFactory.createTitledBorder(null,
						"\u6846\u67b6\u4fe1\u606f", TitledBorder.LEADING,
						TitledBorder.DEFAULT_POSITION));
				{
					frameStruts = new JCheckBox();
					jPanel1.add(frameStruts, new GridBagConstraints(0, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.WEST,
							GridBagConstraints.NONE, new Insets(0, 20, 0, 0),
							0, 0));
					frameStruts.setText("Struts2");
				}
				{
					frameSping = new JCheckBox();
					jPanel1.add(frameSping, new GridBagConstraints(1, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.WEST,
							GridBagConstraints.NONE, new Insets(0, 20, 0, 0),
							0, 0));
					frameSping.setText("Spring");
				}
				{
					frameHibernate = new JCheckBox();
					jPanel1.add(frameHibernate, new GridBagConstraints(2, 0, 1,
							1, 0.0, 0.0, GridBagConstraints.WEST,
							GridBagConstraints.NONE, new Insets(0, 20, 0, 0),
							0, 0));
					frameHibernate.setText("Hibernate");
				}
				{
					frameJPA = new JCheckBox();
					jPanel1.add(frameJPA, new GridBagConstraints(3, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.WEST,
							GridBagConstraints.NONE, new Insets(0, 20, 0, 0),
							0, 0));
					frameJPA.setText("JPA");
				}
				{
					frameBatis = new JCheckBox();
					jPanel1.add(frameBatis, new GridBagConstraints(4, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.WEST,
							GridBagConstraints.NONE, new Insets(0, 20, 0, 0),
							0, 0));
					frameBatis.setText("IBatis");
				}
			}
			{
				group = new JTextField();
				contentPanel.add(group, new GridBagConstraints(1, 0, 2, 1, 0.0,
						0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
						new Insets(0, 0, 0, 0), 0, 0));
				group.setPreferredSize(new java.awt.Dimension(495, 24));
			}
			{
				projectDirLB = new JLabel();
				contentPanel.add(projectDirLB, new GridBagConstraints(0, 1, 1,
						1, 0.0, 0.0, GridBagConstraints.EAST,
						GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
				projectDirLB.setText("\u9879\u76ee\u8def\u5f84:");
			}
			{
				projectDir = new JTextField();
				contentPanel.add(projectDir, new GridBagConstraints(1, 1, 1, 1,
						0.0, 0.0, GridBagConstraints.WEST,
						GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
				projectDir.setPreferredSize(new java.awt.Dimension(414, 24));
			}
			{
				browe = new JButton();
				contentPanel.add(browe, new GridBagConstraints(2, 1, 1, 1, 0.0,
						0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
						new Insets(0, 0, 0, 0), 0, 0));
				browe.setText("\u6d4f\u89c8");
				browe.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						int returnVal = chooser.showOpenDialog(Generator.this);
						if (returnVal == JFileChooser.APPROVE_OPTION) {
							File file = chooser.getSelectedFile();
							projectDir.setText(file.getAbsolutePath());
						}
					}
				});
			}
			{
				jPanel2 = new JPanel();
				GridBagLayout jPanel2Layout = new GridBagLayout();
				contentPanel.add(jPanel2, new GridBagConstraints(0, 3, 3, 1,
						0.0, 0.0, GridBagConstraints.CENTER,
						GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
				jPanel2Layout.rowWeights = new double[] { 0.1, 0.1, 0.1 };
				jPanel2Layout.rowHeights = new int[] { 7, 7, 7 };
				jPanel2Layout.columnWeights = new double[] { 0.0, 0.1, 0.0, 0.1 };
				jPanel2Layout.columnWidths = new int[] { 90, 7, 90, 7 };
				jPanel2.setLayout(jPanel2Layout);
				jPanel2.setBorder(BorderFactory
						.createTitledBorder("\u6570\u636e\u5e93\u4fe1\u606f"));
				{
					hostnameLb = new JLabel();
					jPanel2.add(hostnameLb, new GridBagConstraints(2, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					hostnameLb.setText("\u4e3b\u673a\u540d:");
				}
				{
					usernameLb = new JLabel();
					jPanel2.add(usernameLb, new GridBagConstraints(0, 2, 1, 1,
							0.0, 0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					usernameLb.setText("\u7528\u6237\u540d:");
				}
				{
					username = new JTextField();
					jPanel2.add(username, new GridBagConstraints(1, 2, 1, 1,
							0.0, 0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					username.setPreferredSize(new java.awt.Dimension(176, 24));
				}
				{
					passwordLb = new JLabel();
					jPanel2.add(passwordLb, new GridBagConstraints(2, 2, 1, 1,
							0.0, 0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					passwordLb.setText("\u5bc6\u7801:");
				}
				{
					password = new JPasswordField();
					jPanel2.add(password, new GridBagConstraints(3, 2, 1, 1,
							0.0, 0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					password.setPreferredSize(new java.awt.Dimension(176, 24));
				}
				{
					databaseType = new JComboBox();
					jPanel2.add(databaseType, new GridBagConstraints(1, 0, 1,
							1, 0.0, 0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					databaseType.setPreferredSize(new java.awt.Dimension(176,
							24));
					databaseType.setRenderer(new DefaultListCellRenderer() {

						/**
						 * 
						 */
						private static final long serialVersionUID = 1L;

						public Component getListCellRendererComponent(
								JList list, Object value, int index,
								boolean isSelected, boolean cellHasFocus) {
							super.getListCellRendererComponent(list, value,
									index, isSelected, cellHasFocus);
							if (value instanceof DatabaseInfo) {
								DatabaseInfo mec = (DatabaseInfo) value;
								setText(mec.getDatabaseType());
							}
							return this;
						}
					});
					databaseType.addItemListener(new ItemListener() {

						@Override
						public void itemStateChanged(ItemEvent e) {
							Object value = databaseType.getSelectedItem();
							if (value instanceof DatabaseInfo) {
								DatabaseInfo info = (DatabaseInfo) value;
								if ("".equals(port.getText().trim())) {
									port.setText(info.getPort().toString());
								}
							}
						}
					});
				}
				{
					databaseTypeLb = new JLabel();
					jPanel2.add(databaseTypeLb, new GridBagConstraints(0, 0, 1,
							1, 0.0, 0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					databaseTypeLb.setText("\u6570\u636e\u5e93\u7c7b\u578b:");
				}
				{
					hostname = new JTextField();
					jPanel2.add(hostname, new GridBagConstraints(3, 0, 1, 1,
							0.0, 0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					hostname.setPreferredSize(new java.awt.Dimension(176, 24));
				}
				{
					portLb = new JLabel();
					jPanel2.add(portLb, new GridBagConstraints(0, 1, 1, 1, 0.0,
							0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					portLb.setText("\u7aef\u53e3:");
				}
				{
					port = new JTextField();
					jPanel2.add(port, new GridBagConstraints(1, 1, 1, 1, 0.0,
							0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					port.setPreferredSize(new java.awt.Dimension(176, 24));
				}
				{
					database = new JTextField();
					jPanel2.add(database, new GridBagConstraints(3, 1, 1, 1,
							0.0, 0.0, GridBagConstraints.CENTER,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					database.setPreferredSize(new java.awt.Dimension(176, 24));
				}
				{
					databaseLb = new JLabel();
					jPanel2.add(databaseLb, new GridBagConstraints(2, 1, 1, 1,
							0.0, 0.0, GridBagConstraints.EAST,
							GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0,
							0));
					databaseLb.setText("\u6570\u636e\u5e93:");
				}
			}
			contentPane(contentPanel);
			contentPanelLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.1 };
			contentPanelLayout.rowHeights = new int[] { 30, 30, 30, 20 };
			contentPanelLayout.columnWeights = new double[] { 0.0, 0.0, 0.0 };
			contentPanelLayout.columnWidths = new int[] { 70, 425, 96 };
		}
		this.setSize(608, 336);
		SwingHelper.center(this);
		initDataBindings();
	}

	public void contentPane(JPanel contentPanel) {

	}

	public void buttonPane(JPanel buttonPanel) {
		next = new JButton();
		buttonPanel.add(next);
		next.setText("\u4e0b\u4e00\u6b65");
		next.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				nextActionPerformed(evt);
			}
		});

		cancel = new JButton();
		buttonPanel.add(cancel);
		cancel.setText("\u53d6\u6d88");
	}

	private void nextActionPerformed(ActionEvent evt) {
		try {
			validateData();
		} catch (SwingException e) {
			JOptionPane.showMessageDialog(this, e.getMessage());
		}
	}

	private void validateData() throws SwingException {
		EntityUtil.validate(project);
		EntityUtil.validate(generatorInfo);
		ServiceReference<ProjectPersistenceService> serRef = context
				.getServiceReference(ProjectPersistenceService.class);
		ProjectPersistenceService service = context.getService(serRef);
		project.getProperties().clear();
		EntityUtil.entityToMap(project, generatorInfo, "generatorInfo");
		Hashtable<String, Object> dir = new Hashtable<String, Object>();
		dir.put(ProjectService.PROJECT_TYPE, PROJECT_TYPE);
		project.setType(PROJECT_TYPE);
		if (project.getId() == null) {
			service.add(project);
		} else {
			service.update(project);
			ProjectService.projectServiceRegistration.get(project.getId())
					.unregister();
		}
		dir.put(ProjectService.PROJECT_ID, project.getId());
		GeneratorProjectService projectService = new GeneratorProjectService(
				context);
		projectService.setProject(project);
		ServiceRegistration<ProjectService> registerService = context
				.registerService(ProjectService.class, projectService, dir);
		ProjectService.projectServiceRegistration.put(project.getId(),
				registerService);
		this.dispose();
		context.ungetService(serRef);
	}

	public GeneratorInfo getGeneratorInfo() {
		return generatorInfo;
	}

	public void setGeneratorInfo(GeneratorInfo generatorInfo) {
		EntityUtil.popetyCopy(generatorInfo, this.generatorInfo);
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		EntityUtil.popetyCopy(project, this.project);
	}

	protected void initDataBindings() {
		JComboBoxBinding<DatabaseInfo, List<DatabaseInfo>, JComboBox> createJComboBoxBinding = SwingBindings
				.createJComboBoxBinding(UpdateStrategy.READ, databaseInfos,
						databaseType);
		createJComboBoxBinding.bind();
		if (databaseInfos.size() > 0) {
			databaseType.setSelectedIndex(0);
		}
		BeanProperty<Object, String> beanProperty = BeanProperty.create("name");
		BeanProperty<JTextField, String> textFieldBeanProperty = BeanProperty
				.create("text");
		AutoBinding<Object, String, JTextField, String> createAutoBinding = Bindings
				.createAutoBinding(UpdateStrategy.READ_WRITE, project,
						beanProperty, projectName, textFieldBeanProperty);
		createAutoBinding.bind();
		beanProperty = BeanProperty.create("group");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty, group,
				textFieldBeanProperty);
		createAutoBinding.bind();

		beanProperty = BeanProperty.create("dir");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty,
				projectDir, textFieldBeanProperty);
		createAutoBinding.bind();

		beanProperty = BeanProperty.create("port");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty, port,
				textFieldBeanProperty);
		createAutoBinding.bind();

		beanProperty = BeanProperty.create("hostname");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty,
				hostname, textFieldBeanProperty);
		createAutoBinding.bind();

		beanProperty = BeanProperty.create("username");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty,
				username, textFieldBeanProperty);
		createAutoBinding.bind();

		beanProperty = BeanProperty.create("password");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty,
				password, textFieldBeanProperty);
		createAutoBinding.bind();
		beanProperty = BeanProperty.create("database");
		createAutoBinding = Bindings.createAutoBinding(
				UpdateStrategy.READ_WRITE, generatorInfo, beanProperty,
				database, textFieldBeanProperty);
		createAutoBinding.bind();

		BeanProperty<GeneratorInfo, Boolean> generatorInfoBeanProperty = BeanProperty
				.create("frameStruts");
		BeanProperty<JCheckBox, Boolean> jCheckBoxBeanProperty = BeanProperty
				.create("selected");
		AutoBinding<GeneratorInfo, Boolean, JCheckBox, Boolean> autoBinding = Bindings
				.createAutoBinding(UpdateStrategy.READ_WRITE, generatorInfo,
						generatorInfoBeanProperty, frameStruts,
						jCheckBoxBeanProperty);
		autoBinding.bind();

		generatorInfoBeanProperty = BeanProperty.create("frameBatis");
		autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
				generatorInfo, generatorInfoBeanProperty, frameBatis,
				jCheckBoxBeanProperty);
		autoBinding.bind();

		generatorInfoBeanProperty = BeanProperty.create("frameHibernate");
		autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
				generatorInfo, generatorInfoBeanProperty, frameHibernate,
				jCheckBoxBeanProperty);
		autoBinding.bind();

		generatorInfoBeanProperty = BeanProperty.create("frameJPA");
		autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
				generatorInfo, generatorInfoBeanProperty, frameJPA,
				jCheckBoxBeanProperty);
		autoBinding.bind();

		generatorInfoBeanProperty = BeanProperty.create("frameSping");
		autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
				generatorInfo, generatorInfoBeanProperty, frameSping,
				jCheckBoxBeanProperty);
		autoBinding.bind();
	}
}
